package com.example.parkdemo.visitor

import androidx.lifecycle.MutableLiveData
import com.example.base.mvvm.BaseViewModel
import com.example.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class VisitorViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val visitorSuccess by lazy { MutableLiveData<String>() }
    fun getVisitor(body: RequestBody) {
        executeNetWork(
            { apiService.selVisitor(body) },
            visitorSuccess::postValue
        )
    }

    val addVisitorSuccess by lazy { MutableLiveData<String>() }
    fun getAddVisitor(body: RequestBody) {
        executeNetWork(
            { apiService.addVisitor(body) },
            addVisitorSuccess::postValue
        )
    }

    val deleteSuccess by lazy { MutableLiveData<String>() }
    fun getDeleteSuccess(body: RequestBody) {
        executeNetWork(
            { apiService.deleteVisitor(body) },
            deleteSuccess::postValue
        )
    }
}